#include <iostream>
using namespace std;
const int N = 5e6+5;
int a[N],b[N],c[N];
int rd(){
	int a;
	scanf("%d",&a);
	return a;
}
int main()
{
    int n,m;
    n=rd();m=rd();
    for (int i = 1; i <= n; i ++ )
         a[i]=rd();
    for (int j = 1; j <= n; j ++ )
    {
        b[j]=a[j]-a[j-1];
    }
    while (m -- )
    {
        int x,y,z;
        x=rd();y=rd();z=rd();
        b[x]=b[x]+z;
        b[y+1]=b[y+1]-z;
    }
    int sum=0;
    for (int i = 1; i <= n; i ++ )
    {   
        sum=sum+b[i];
        c[i]=sum;
    }
    int min=N;
    for (int i = 1; i <= n; i ++ ){
   // 	a[i]=a[i-1]+b[i];
    	if(c[i]<min) min=c[i];
	}
	printf("%d",min);
    return 0;
}